#define _CRT_SECURE_NO_WARNINGS 1

class Solution {
public:
    bool isZeroArray(vector<int>& nums, vector<vector<int>>& queries) {
        int n = nums.size();
        vector<int> diff(n + 1);
        for (auto& vec : queries)
        {
            diff[vec[0]]++;
            diff[vec[1] + 1]--;
        }
        int change = 0;
        for (int i = 0; i < n; i++)
        {
            change += diff[i];
            if (nums[i] > change)
                return false;
        }
        return true;
    }
};